new Vue({
	el: "#app",
	data: {
		signCount: 0,
		signResult: '快来签到领取积分吧',
		isTodaySign: !0,
		isDraw: true,
		luckCount: 0,
		isExcute:false,
		imgList:[]
	},
	methods: {
		getSignCount: function() {
			var t = this;
			wx.showLoading({
				title: "加载中...",
				mask: !0,
				success: function(t) {}
			}), this.$http.post(baseUrl + "api/sign/signCount", {
				t: 1
			}).then(function(e) {
				wx.hideLoading();
				var n = e.data;
				if (n.success) {
					t.signCount = n.data;
				} else {
					wx.showToast({
						title: n.description,
						icon: "none",
						duration: 2e3,
						mask: !1
					});
				}
			}).catch(function(t) {
				console.log(t), wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			});
		},
		getLuckCount: function() {
			var t = this;
			wx.showLoading({
				title: "加载中...",
				mask: !0,
				success: function(t) {}
			}), this.$http.get(baseUrl + "luck/count").then(function(e) {
				wx.hideLoading();
				var n = e.data;
				if (n.success) {
					t.luckCount = n.data;
				} else {
					wx.showToast({
						title: n.description,
						icon: "none",
						duration: 2e3,
						mask: !1
					});
				}
			}).catch(function(t) {
				console.log(t), wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			});
		},
		sign: function() {
			if (this.isTodaySign) {
				wx.showToast({
					title: "今日已签到",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			}
			var t = this;
			wx.showLoading({
				title: "加载中...",
				mask: !0,
				success: function(t) {}
			}), this.$http.post(baseUrl + "api/sign/userSign", {}).then(function(e) {
				wx.hideLoading();
				var n = e.data;
				if (n.success) {
					t.signResult = "恭喜您获得" + n.data + "积分";
					t.isTodaySign = true;
					wx.showToast({
						title: "恭喜您签到成功",
						icon: "none",
						duration: 2e3,
						mask: !1
					});
					t.getSignCount();
					t.getLuckCount();
				} else {
					wx.showToast({
						title: n.description,
						icon: "none",
						duration: 2e3,
						mask: !1
					});
				}
			}).catch(function(t) {
				console.log(t), wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			});
		},
		getTodaySign: function() {
			var t = this;
			wx.showLoading({
				title: "加载中...",
				mask: !0,
				success: function(t) {}
			}), this.$http.post(baseUrl + "api/sign/isTodaySign", {}).then(function(e) {
				wx.hideLoading();
				var n = e.data;
				if (n.success) {
					t.isTodaySign = n.data;
					if (n.data) {
						t.signResult = "今日已签到";
					}
				} else {
					wx.showToast({
						title: n.description,
						icon: "none",
						duration: 2e3,
						mask: !1
					});
				}
			}).catch(function(t) {
				console.log(t), wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			});
		},
		draw: function() {
			if (this.luckCount < 1) {
				return;
			}
			if(this.isExcute){
				return;
			}
			this.isExcute = true;
			var t = this;
			this.$http.post(baseUrl + "luck/draw", {}).then(function(e) {
				wx.hideLoading();
				var n = e.data;
				if (n.success) {
					this.luckCount--;
					var luck = n.data;
					var luckDraw = new LuckDraw({});
					if (luck.luckName) {
						luckDraw._init({
							rotateId: '#luckPointer',
							luckNumber:luck.sort-1,
							typeNumber: 4,
							time: 2000,
							type: 'turntable',
							circleNumber: 10,
							success: function(res) {
								t.isExcute = false;
								var remark = "";
								if(luck.remark!=null && luck.remark !=""){
									remark = "温馨提示您:"+luck.remark;
								}
								$(document).dialog({
									type: 'confirm',
									titleText: "恭喜您，中奖啦！",
									position: 'center',
									content: "亲！恭喜您抽中“" + luck.luckName + "”！可前往“我的奖品”页面查看您的中奖记录哟" + remark,
									buttonTextConfirm: "好的",
								});
							}
						});
					} else {
						luckDraw._init({
							rotateId: '#luckPointer',
							luckNumber:luck.sort-1,
							typeNumber: 4,
							time: 2000,
							type: 'turntable',
							circleNumber: 10,
							success: function(res) {
								t.isExcute = false;
								$(document).dialog({
									type: 'confirm',
									titleText: "很遗憾,什么都没有抽中!",
									position: 'center',
									content: "亲！很遗憾，您什么都没有抽中！请再接再厉，继续签到获得更多的抽奖机会！",
									buttonTextConfirm: "好的",
								});
							},
						});
					}
				} else {
					wx.showToast({
						title: n.description,
						icon: "none",
						duration: 2e3,
						mask: !1
					});
					this.isExcute = false;
				}
			}).catch(function(t) {
				this.isExcute = false;
				console.log(t), wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			});
		},
		getLuckList:function(){
			var t = this;
			wx.showLoading({
				title: "加载中...",
				mask: !0,
				success: function(t) {}
			}), this.$http.get(baseUrl + "luck/list").then(function(e) {
				wx.hideLoading();
				var n = e.data;
				if (n.success) {
					n.data.forEach(function(item){
						t.imgList.push(item.luckName);
					});
				} else {
					wx.showToast({
						title: n.description,
						icon: "none",
						duration: 2e3,
						mask: !1
					});
				}
			}).catch(function(t) {
				console.log(t), wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			});
		}
	},
	created: function() {
		login._2page();
		this.getSignCount();
		this.getTodaySign();
		this.getLuckList();
		this.getLuckCount();
	}
});
